package cn.mastor.quartz;


import cn.mastor.domain.Comment;
import cn.mastor.redisUtilService.RedisUtilService;
import cn.mastor.service.ICommentService;
import cn.mastor.utlis.SpringUtils;
import lombok.extern.slf4j.Slf4j;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.quartz.QuartzJobBean;

import java.text.SimpleDateFormat;

/**
 * 点赞的定时任务
 */
@Slf4j
public class LikeTask extends QuartzJobBean {
    @Autowired
    RedisUtilService redisUtilService;
    @Autowired
    ICommentService commentService;
    private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    @Override
    protected void executeInternal(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        ICommentService commentService = SpringUtils.getBean(ICommentService.class);
        Comment comment = new Comment();
        comment.setText("hahahahaa");
        commentService.insert(comment);
//        log.info("LikeTask-------- {}", sdf.format(new Date()));

        //将 Redis 里的点赞信息同步到数据库里

    }
}